[PHP] Singleton class and using inheritance

Posted by Saif Bechan on Stack Overflow See other posts from Stack Overflow or by Saif Bechan
Published on 2010-03-08T13:03:53Z Indexed on 2010/03/08 13:06 UTC
Read the original article Hit count: 847

Filed under:
|
|
|

I have am working on a web application that makes use of helper classes. These classes hold functions to various operation such as form handling.

Sometimes I need these classes at more than one spot in my application, The way I do it now is to make a new Object. I can't pass the variable, this will be too much work.

I was wondering of using singleton classes for this. This way I am sure only one instance is running at a time.

My question however is when I use this pattern, should I make a singleton class for all the objects, this would b a lot of code replication.

Could I instead make a super class of superHelper, which is a singleton class, and then let every helper extend it.

Would this sort of set up work, or is there another alternative?

And if it works, does someone have any suggestions on how to code such a superHelper class.

Thank you guys

© Stack Overflow or respective owner

Related posts about php

Related posts about singleton